package shapewar.engine.presenter;
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;

import shapewar.engine.intefac.IRegisterable;

public class MyTreeSet <T extends IRegisterable>{
	public static int DESC = 1;
	public static int ORDER_BY_ID = 0;
	public static int INC = -1;
	private TreeSet1<T> tree;
	public MyTreeSet(final int k){
		if(k!=ORDER_BY_ID){
			tree = new TreeSet1<T>(new Comparator<T>() {
				@Override
				public int compare(T o1, T o2) {
					return (o1.getKey()-o2.getKey()) * k;
				}
			});
		}else{
			tree = new TreeSet1<T>(new Comparator<T>() {
				@Override
				public int compare(T arg0, T arg1) {
					return arg1.getId() - arg0.getId();
				}
			});
		}
	}
	public int size(){
		return tree.size();
	}
	public Iterator<T> iterator(){
		return tree.iterator();
	}
	
	public void add(T t){
		tree.add(t);
	}

	public void remove(T t) {
		tree.remove(t);
	}

	public void add(T t,boolean b){
		tree.add(t,b);
	}

	public void remove(T t, boolean b) {
		tree.remove(t, b);
	}

	public void clear() {
		tree.clear();
	}

	public void valid() {
		tree.valid();
	}
}